/* ServerApp.java 
* Created on Dec 6, 2012 
*@Author: Mr.Viet 
*@Phone: 01683430426 
*@Email: phamvanvietcdhd@gmail.com
*/ 
package com.session8; 

import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerApp {
	private ServerSocket server;
	private final int PORT = 1000;
	private boolean running = true;
	public ServerApp() {
	}

	public static void main(String[] args) {
		ServerApp app = new ServerApp();
		System.out.println("Server is running...");
		app.createServer();
	}
	public void createServer(){
		try {
			this.server = new ServerSocket(this.PORT);
			while(this.running){
				Socket client = this.server.accept();
				ClientListener tai = new ClientListener(client);
				tai.start();
				System.out.println("Da Ket Noi...");
				PrintWriter out = new PrintWriter(client.getOutputStream());
				out.println("Hello Client...");
				out.flush();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
